/*
 * JHeuristics - The Java Meta-Heuritics Library
 * Copyright (C) 2004-2005, Universidade Federal de Campina Grande. All rights reserved.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.jheuristics.util.conditions;

import org.jheuristics.util.Condition;

/**
 * TODO
 *
 * @author Marcell Manfrin, marcell@ourgrid.org, Jan 9, 2006
 */
public class AndCondition implements Condition {
	private Condition condition1;
	private Condition condition2;

	/**
	 * TODO
	 *
	 * @param condition1
	 * @param condition2
	 */
	public AndCondition(Condition condition1, Condition condition2) {
		setCondition1(condition1);
		setCondition2(condition2);
	}

	/**
	 * TODO
	 *
	 * @param obj
	 * @return
	 * @see org.jheuristics.util.Condition#check(java.lang.Object)
	 */
	public boolean check(Object obj) {
		return condition1.check(obj) && condition2.check(obj);
	}

	/**
	 * TODO
	 *
	 * @return
	 */
	public Condition getCondition1() {
		return condition1;
	}

	/**
	 * TODO
	 *
	 * @param condition
	 */
	public void setCondition1(Condition condition) {
		if (null == condition) {
			// TODO: ERROR MSG
			throw new NullPointerException();
		}
		this.condition1 = condition;
	}

	/**
	 * TODO
	 *
	 * @return
	 */
	public Condition getCondition2() {
		return condition2;
	}

	/**
	 * TODO
	 *
	 * @param condition
	 */
	public void setCondition2(Condition condition) {
		if (null == condition) {
			// TODO: ERROR MSG
			throw new NullPointerException();
		}
		this.condition2 = condition;
	}

}
